package com.example.secondhandsysapi.Mapper;

import com.example.secondhandsysapi.Entity.LookLogInfo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.List;

@Mapper
public interface LookLogInfoMapper {
    @Delete("delete from look_log where look_id=#{look_id}")
    Integer deleteByLookId(Integer look_id);
    //查询所有
@Select("SELECT * FROM look_log")
List<LookLogInfo> getAllLookLogInfoAll();

//根据用户ID查询
@Select("SELECT * FROM look_log where user_id=#{user_id}")
    List<LookLogInfo> getAllLookLogInfoByUserId(Integer user_id);

    @Select("SELECT * FROM look_log where log_time like '%${log_time}%'")
    List<LookLogInfo> getAllLookLogInfoByTime(Date log_time);

//根据访问页面查询
@Select("SELECT * FROM look_log where log_page like '%${log_page}%'")
    List<LookLogInfo> getAllLookLogInfoByPage(String log_page);

    @Select("SELECT * FROM look_log where user_id=#{user_id} and log_time like CONCAT('%', #{log_time}, '%')")
    List<LookLogInfo> getAllLookLogInfoByUserIdTime(@Param("user_id") Integer user_id,@Param("log_time") Date log_time);

    @Select("SELECT * FROM look_log where log_time like CONCAT('%', #{log_time}, '%') and log_page like CONCAT('%', #{log_page}, '%')")
    List<LookLogInfo> getAllLookLogInfoByTimePage(@Param("log_time") Date log_time, @Param("log_page") String log_page);

    @Select("SELECT * FROM look_log where user_id=#{user_id} and log_page like CONCAT('%', #{log_page}, '%')")
    List<LookLogInfo> getAllLookLogInfoByUserIdPage(@Param("user_id") Integer user_id, @Param("log_page") String log_page);

    @Select("SELECT * FROM look_log where user_id=#{user_id} and log_time like CONCAT('%', #{log_time}, '%') and log_page like CONCAT('%', #{log_page}, '%')")
    List<LookLogInfo> getAllLookLogInfoByUserIdTimePage(@Param("user_id") Integer user_id, @Param("log_time") Date log_time, @Param("log_page") String log_page);


    List<LookLogInfo> getAllLookLogInfoByTime(String formatStr);

    List<LookLogInfo> getAllLookLogInfoByRole(Integer role);
}
